package com.example.simpleforum.model;

import java.sql.Timestamp;

/**
 * 用户实体类
 */
public class User {
    private int id;             // 用户ID，主键，自增
    private String username;    // 用户名，唯一
    private String password;    // 密码，加密存储
    private Timestamp registerTime; // 注册时间

    // 构造函数
    public User() {
    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
        this.registerTime = new Timestamp(System.currentTimeMillis());
    }

    public User(int id, String username, String password, Timestamp registerTime) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.registerTime = registerTime;
    }

    // Getter和Setter方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Timestamp getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Timestamp registerTime) {
        this.registerTime = registerTime;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", registerTime=" + registerTime +
                '}';
    }
}